﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MockPrjTeam2.Biz;
using MockPrjTeam2.Entity;

namespace MockPrjTeam2.Pages.Forms
{
    public partial class ServiceDetail : System.Web.UI.Page
    {
        private int _serviceId;
        private static List<Service> _listService;
        private readonly ServiceBiz _serviceBiz = new ServiceBiz();

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            string script = @"<script>
            function OpenPopup() {
                popup('/Pages/Views/PopupListContacts.aspx');
            }
            function OpenPopup1() {
                popup('PopupListContacts1.aspx');
            }
            function popup(url) {

                var width = 500;
                var height = 400;
                var left = (screen.width - width) / 2;
                var top = (screen.height - height) / 2;
                var params = 'width=' + width + ', height=' + height;
                params += ', top=' + top + ', left=' + left;
                params += ', directories=no';
                params += ', location=no';
                params += ', menubar=no';
                params += ', resizable=no';
                params += ', scrollbars=no';
                params += ', status=no';
                params += ', toolbar=no';
                newwin = window.open(url, 'windowname5', params);
                if (window.focus) { newwin.focus() }
                return false;
            }
            </script>";
            if (!Page.ClientScript.IsStartupScriptRegistered("Mast"))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(),
                    "Mast", script);
            }
            if (!int.TryParse(Request.Params["id"], out _serviceId))
            {
                return;
            }
            if (Session["contact"] != null || Session["contact1"] != null)
            {
                var o = Session["contact"];
                if (o != null) txtContact.Text = o.ToString();
                var s = Session["contact1"];
                if (s != null) txtContact1.Text = Session["contact1"].ToString();
            }
            if (!IsPostBack)
            {
                GetServiceById();
            }
            CheckTabs();
        }

        protected void CheckTabs()
        {
            if (cboServiceType.SelectedIndex == 0)
            {
                pnlContract.Visible = false;
                pnlFunding.Visible = false;
                LinkContract.Text = string.Empty;
                LinkContract.NavigateUrl = string.Empty;
            }

            if (cboServiceType.SelectedIndex == 1)
            {
                pnlFunding.Visible = false;
                pnlContract.Visible = true;
                LinkContract.NavigateUrl = "#pnlContract";
                LinkContract.Text = "Contract";
            }

            if (cboServiceType.SelectedIndex == 2)
            {
                pnlContract.Visible = false;
                pnlFunding.Visible = true;
                LinkContract.NavigateUrl = "#pnlFunding";
                LinkContract.Text = "Funding";
            }
        }

        /// <summary>
        /// Gets the service by id.
        /// </summary>
        private void GetServiceById()
        {
            _listService = _serviceBiz.GetById(_serviceId);
            if (_listService != null)
            {
                foreach (var service in _listService)
                {
                    var serviceBenefitsCriterion = service.ServiceBenefitsCriterion.Split(';');
                    var serviceBarriersCriterion = service.ServiceBarriersCriterion.Split(';');
                    var serviceEthnicityCriterion = service.ServiceEthnicityCriterion.Split(';');
                    var serviceDisabilityCriterion = service.ServiceDisabilityCriterion.Split(';');
                    var servicePersonalCircumtancesCriterion =
                        service.ServicePersonalCircumtancesCriterion.Split(';');
                    var otherServiceParticipationCriterion =
                        service.OtherServiceParticipationCriterion.Split(';');
                    var clientSuportProcess = service.ClientSuportProcess.Split(';');
                    var intervention = service.Intervention.Split(';');
                    var clientJourney = service.ClientJourney.Split(';');
                    var clientOutcome = service.ClientOutcome.Split(';');
                    var targetClient = service.TargetClient.Split(';');
                    var accreditations = service.Accreditations.Split(';');
                    var referalSources = service.ReferalSources.Split(';');
                    var contractOutcome = service.ContractOutcome.Split(';');
                    var contractObligation = service.ContractObligation.Split(';');

                    txtServiceName.Text = service.ServiceName;
                    chkServiceActive.Checked = service.IsActive;
                    txtShortDescription.Text = service.ServiceShortDescription;
                    cboSubType.SelectedValue = service.SubType;
                    txtServiceFullDescription.Text = service.ServiceFullDescription;
                    txtDeptCode.Text = service.DeptCode;
                    txtContact.Text = service.ContactName;
                    hdnContactId.Value = service.ContactId.ToString(CultureInfo.InvariantCulture);
                    cboServiceType.SelectedValue = service.ServiceType;
                    txtClientDescription.Text = service.ClientDescription;
                    txtServiceDescriptionDelivery.Text = service.ServiceDescriptionDelivery;
                    cboServiceAttendance.SelectedValue = service.ServiceAttendance;
                    txtServiceContractCode.Text = service.ServiceContactCode;
                    txtServiceStartExpected.Text = service.ServiceStartExpected.ToString();
                    txtServiceContractValue.Text = service.ServiceContactValue;
                    txtServiceStartDate.Text = service.ServiceStartDate.ToString();
                    txtServiceEndDate.Text = service.ServiceEndDate.ToString();
                    cboReferralProcessMethod.SelectedValue = service.ReferralProcessMethod;
                    cboExtendableYear.SelectedValue = Convert.ToString(service.ServiceExtendableYear);
                    cboExtendableMonth.SelectedValue = Convert.ToString(service.ServiceExtendableMonth);
                    cboTimeLimitedYear.SelectedValue = Convert.ToString(service.ServiceTimeLimitedYear);
                    cboTimeLimitedMonth.SelectedValue = Convert.ToString(service.ServiceTimeLimitedMonth);
                    foreach (string s in serviceBenefitsCriterion)
                    {
                        if (chkServiceBenefitsCriterion.Items.FindByText(s) != null)
                        {
                            chkServiceBenefitsCriterion.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in serviceBarriersCriterion)
                    {
                        if (chkServiceBarriersCriterion.Items.FindByText(s) != null)
                        {
                            chkServiceBarriersCriterion.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in serviceEthnicityCriterion)
                    {
                        if (chkServiceEthnicityCriterion.Items.FindByText(s) != null)
                        {
                            chkServiceEthnicityCriterion.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in serviceDisabilityCriterion)
                    {
                        if (chkServiceDisabilitiesCriterion.Items.FindByText(s) != null)
                        {
                            chkServiceDisabilitiesCriterion.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in servicePersonalCircumtancesCriterion)
                    {
                        if (chkServicePersonalCircumtancesCriterion.Items.FindByText(s) != null)
                        {
                            chkServicePersonalCircumtancesCriterion.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in otherServiceParticipationCriterion)
                    {
                        if (chkOtherServiceParticipationCriterion.Items.FindByText(s) != null)
                        {
                            chkOtherServiceParticipationCriterion.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in clientSuportProcess)
                    {
                        if (chkClientSuportProcess.Items.FindByText(s) != null)
                        {
                            chkClientSuportProcess.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in intervention)
                    {
                        if (chkIntervention.Items.FindByText(s) != null)
                        {
                            chkIntervention.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in clientJourney)
                    {
                        if (chkClientJourney.Items.FindByText(s) != null)
                        {
                            chkClientJourney.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in clientOutcome)
                    {
                        if (chkClientOutcome.Items.FindByText(s) != null)
                        {
                            chkClientOutcome.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in targetClient)
                    {
                        if (chkTargetClient.Items.FindByText(s) != null)
                        {
                            chkTargetClient.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in accreditations)
                    {
                        if (chkAccreditations.Items.FindByText(s) != null)
                        {
                            chkAccreditations.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in referalSources)
                    {
                        if (chkReferalSources.Items.FindByText(s) != null)
                        {
                            chkReferalSources.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in contractOutcome)
                    {
                        if (cblContractOutcome.Items.FindByText(s) != null)
                        {
                            cblContractOutcome.Items.FindByText(s).Selected = true;
                        }
                    }
                    foreach (string s in contractObligation)
                    {
                        if (cblContractObligation.Items.FindByText(s) != null)
                        {
                            cblContractObligation.Items.FindByText(s).Selected = true;
                        }
                    }
                    cboProgramme.SelectedValue = service.Programme;
                    ddlParticipation.SelectedValue = service.Participation;
                    ddlFundingSource.SelectedValue = service.FundingSource;
                    txtFundingNeed.Text = service.FundingNeeds;
                    txtContact1.Text = service.FundingContactDetails;
                    txtFundingAmount.Text = service.FundingAmount;
                    txtFCAmount.Text = service.FundingContinuationAmount;
                    txtFCDetail.Text = service.FundingContinuationDetails;
                    txtFundingStart.Text = service.FundingStart.ToString();
                    txtFundingEnd.Text = service.FundingEnd.ToString();
                    txtFundraisingForText.Text = service.FundraisingForText;
                    txtFundraisingNeeds.Text = service.FundraisingNeeds;
                    txtFundraisingRequired.Text = service.FundraisingRequiredBy.ToString();
                    txtFundraisingWhy.Text = service.FundraisingWhy;
                    txtFundraisingComplete.Text = service.FundraisingCompletedDate.ToString();
                    txtFDonorAmount.Text = service.FundraisingDonorAmount;
                    txtFDonationDate.Text = service.FundraisingDonationDate.ToString();
                    chkFDonationIncremental.Checked = service.FundraisingDonationIncremental;
                }
            }
        }

        /// <summary>
        /// Gets the programme.
        /// </summary>
        /// <param name="id">The id.</param>
        protected void GetProgramme(int id)
        {
            cboProgramme.DataSource = ProgrammesBIZ.Sp_Programme_GetAll();
            cboProgramme.DataTextField = "ProgrammeName";
            cboProgramme.DataValueField = "ProgrammeID";
            cboProgramme.DataBind();
            cboProgramme.SelectedValue = id.ToString(CultureInfo.InvariantCulture);
        }

        /// <summary>
        /// BTNs the choose start expected click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void BtnChooseStartExpectedClick(object sender, EventArgs e)
        {
            if (calServiceStartExpected.Visible == false)
            {
                calServiceStartExpected.Visible = true;
                btnChooseStartExpected.Text = "-";
            }
            else
            {
                calServiceStartExpected.Visible = false;
                btnChooseStartExpected.Text = "+";
            }
        }

        /// <summary>
        /// Cals the service start expected selection changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void CalServiceStartExpectedSelectionChanged(object sender, EventArgs e)
        {
            txtServiceStartExpected.Text = calServiceStartExpected.SelectedDate.ToString("MM/dd/yyyy");
            calServiceStartExpected.Visible = false;
            btnChooseStartExpected.Text = "+";
        }

        protected void BtnChooseStartDateClick(object sender, EventArgs e)
        {
            if (calServiceStartDate.Visible == false)
            {
                calServiceStartDate.Visible = true;
                btnChooseStartDate.Text = "-";
            }
            else
            {
                calServiceStartDate.Visible = false;
                btnChooseStartDate.Text = "+";
            }
        }

        /// <summary>
        /// Cals the service start date selection changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void CalServiceStartDateSelectionChanged(object sender, EventArgs e)
        {
            txtServiceStartDate.Text = calServiceStartDate.SelectedDate.ToString("MM/dd/yyyy");
            calServiceStartDate.Visible = false;
            btnChooseStartDate.Text = "+";
        }

        /// <summary>
        /// BTNs the choose end date click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void BtnChooseEndDateClick(object sender, EventArgs e)
        {
            if (calServiceEndDate.Visible == false)
            {
                calServiceEndDate.Visible = true;
                btnChooseEndDate.Text = "-";
            }
            else
            {
                calServiceEndDate.Visible = false;
                btnChooseEndDate.Text = "+";
            }
        }

        /// <summary>
        /// Cals the service end date selection changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void CalServiceEndDateSelectionChanged(object sender, EventArgs e)
        {
            txtServiceEndDate.Text = calServiceEndDate.SelectedDate.ToString("MM/dd/yyyy");
            calServiceEndDate.Visible = false;
            btnChooseEndDate.Text = "+";
        }

        /// <summary>
        /// Handles the CheckedChanged event of the chkServiceExtendable control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void chkServiceExtendable_CheckedChanged(object sender, EventArgs e)
        {
            if (chkServiceExtendable.Checked)
            {
                cboExtendableYear.Enabled = true;
                cboExtendableMonth.Enabled = true;
            }
            else
            {
                cboExtendableYear.Enabled = false;
                cboExtendableMonth.Enabled = false;
            }
        }

        /// <summary>
        /// Handles the CheckedChanged event of the chkServiceTimeLimited control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void chkServiceTimeLimited_CheckedChanged(object sender, EventArgs e)
        {
            if (chkServiceTimeLimited.Checked)
            {
                cboTimeLimitedYear.Enabled = true;
                cboTimeLimitedMonth.Enabled = true;
            }
            else
            {
                cboTimeLimitedYear.Enabled = false;
                cboTimeLimitedMonth.Enabled = false;
            }
        }

        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var service = new Service();
            var serviceName = txtServiceName.Text;
            lbMessage.Text = string.Empty;
            var serviceBenefitsCriterion = string.Empty;
            var serviceBarriersCriterion = string.Empty;
            var serviceEthnicityCriterion = string.Empty;
            var serviceDisabilityCriterion = string.Empty;
            var servicePersonalCircumtancesCriterion = string.Empty;
            var otherServiceParticipationCriterion = string.Empty;
            var clientSuportProcess = string.Empty;
            var intervention = string.Empty;
            var clientJourney = string.Empty;
            var clientOutcome = string.Empty;
            var targetClient = string.Empty;
            var accreditations = string.Empty;
            var referalSources = string.Empty;
            var contractOutcome = string.Empty;
            var contractObligation = string.Empty;

            service.ServiceId = _serviceId;
            service.ServiceName = txtServiceName.Text;
            service.ServiceShortDescription = txtShortDescription.Text;
            service.SubType = cboSubType.SelectedValue;
            service.ServiceFullDescription = txtServiceFullDescription.Text;
            service.DeptCode = txtDeptCode.Text;
            service.ContactId = Int32.Parse(hdnContactId.Value);
            service.ServiceType = cboServiceType.SelectedValue;
            service.ClientDescription = txtClientDescription.Text;
            service.ServiceDescriptionDelivery = txtServiceDescriptionDelivery.Text;
            service.ServiceAttendance = cboServiceAttendance.SelectedValue;
            service.ServiceContactCode = txtServiceContractCode.Text;
            service.ServiceStartExpected = txtServiceStartExpected.Text.Equals("") ? DateTime.Now :
                Convert.ToDateTime(txtServiceStartExpected.Text);
            service.ServiceContactValue = txtServiceContractValue.Text;
            var serviceStartDate = Convert.ToDateTime(txtServiceStartDate.Text);
            if (serviceStartDate <= DateTime.Now)
            {
                lbValidateStartDate.Text = "Service Start Date must be greater than the current date.";
            }
            else
            {
                service.ServiceStartDate = serviceStartDate;
                lbValidateStartDate.Text = string.Empty;
            }
            var serviceEndDate = Convert.ToDateTime(txtServiceEndDate.Text);
            if (serviceEndDate <= serviceStartDate)
            {
                lbValidateServiceEndDate.Text =
                    "Service End Date must be greater the Service Start Date.";
            }
            else
            {
                service.ServiceEndDate = serviceEndDate;
                lbValidateServiceEndDate.Text = string.Empty;
            }
            service.ReferralProcessMethod = cboReferralProcessMethod.SelectedValue;
            service.ServiceExtendableYear = Convert.ToInt32(cboExtendableYear.SelectedValue);
            service.ServiceExtendableMonth = Convert.ToInt32(cboExtendableMonth.SelectedValue);
            service.ServiceTimeLimitedYear = Convert.ToInt32(cboTimeLimitedYear.SelectedValue);
            service.ServiceTimeLimitedMonth = Convert.ToInt32(cboTimeLimitedMonth.SelectedValue);
            foreach (ListItem item in chkServiceBenefitsCriterion.Items)
            {
                if (item.Selected)
                {
                    serviceBenefitsCriterion += item.Value + ";";
                }
            }
            foreach (ListItem item in chkServiceBarriersCriterion.Items)
            {
                if (item.Selected)
                {
                    serviceBarriersCriterion += item.Value + ";";
                }
            }
            foreach (ListItem item in chkServiceEthnicityCriterion.Items)
            {
                if (item.Selected)
                {
                    serviceEthnicityCriterion += item.Value + ";";
                }
            }
            foreach (ListItem item in chkServiceDisabilitiesCriterion.Items)
            {
                if (item.Selected)
                {
                    serviceDisabilityCriterion += item.Value + ";";
                }
            }
            foreach (ListItem item in chkServicePersonalCircumtancesCriterion.Items)
            {
                if (item.Selected)
                {
                    servicePersonalCircumtancesCriterion += item.Value + ";";
                }
            }
            foreach (ListItem item in chkOtherServiceParticipationCriterion.Items)
            {
                if (item.Selected)
                {
                    otherServiceParticipationCriterion += item.Value + ";";
                }
            }
            foreach (ListItem item in chkClientSuportProcess.Items)
            {
                if (item.Selected)
                {
                    clientSuportProcess += item.Value + ";";
                }
            }
            foreach (ListItem item in chkIntervention.Items)
            {
                if (item.Selected)
                {
                    intervention += item.Value + ";";
                }
            }
            foreach (ListItem item in chkClientJourney.Items)
            {
                if (item.Selected)
                {
                    clientJourney += item.Value + ";";
                }
            }
            foreach (ListItem item in chkClientOutcome.Items)
            {
                if (item.Selected)
                {
                    clientOutcome += item.Value + ";";
                }
            }
            foreach (ListItem item in chkTargetClient.Items)
            {
                if (item.Selected)
                {
                    targetClient += item.Value + ";";
                }
            }
            foreach (ListItem item in chkAccreditations.Items)
            {
                if (item.Selected)
                {
                    accreditations += item.Value + ";";
                }
            }
            foreach (ListItem item in chkReferalSources.Items)
            {
                if (item.Selected)
                {
                    referalSources += item.Value + ";";
                }
            }
            foreach (ListItem item in cblContractOutcome.Items)
            {
                if (item.Selected)
                {
                    contractOutcome += item.Value + ";";
                }
            }
            foreach (ListItem item in cblContractObligation.Items)
            {
                if (item.Selected)
                {
                    contractObligation += item.Value + ";";
                }
            }
            service.ServiceBenefitsCriterion = serviceBenefitsCriterion;
            service.ServiceBarriersCriterion = serviceBarriersCriterion;
            service.ServiceEthnicityCriterion = serviceEthnicityCriterion;
            service.ServiceDisabilityCriterion = serviceDisabilityCriterion;
            service.ServicePersonalCircumtancesCriterion = servicePersonalCircumtancesCriterion;
            service.OtherServiceParticipationCriterion = otherServiceParticipationCriterion;
            service.ClientSuportProcess = clientSuportProcess;
            service.Intervention = intervention;
            service.ClientJourney = clientJourney;
            service.ClientOutcome = clientOutcome;
            service.TargetClient = targetClient;
            service.Accreditations = accreditations;
            service.ReferalSources = referalSources;
            service.Programme = cboProgramme.SelectedValue;
            service.ContractOutcome = contractOutcome;
            service.ContractObligation = contractObligation;
            service.Participation = ddlParticipation.SelectedValue;
            service.FundingSource = ddlFundingSource.SelectedValue;
            service.FundingNeeds = txtFundingNeed.Text;
            service.FundingContactDetails = txtContact1.Text;
            service.FundingAmount = txtFundingAmount.Text;
            service.FundingContinuationAmount = txtFCAmount.Text;
            service.FundingContinuationDetails = txtFCDetail.Text;
            foreach (var item in _listService)
            {
                service.FundingStart = item.FundingStart.Equals(DateTime.MinValue) ? (DateTime?)null :
                Convert.ToDateTime(txtFundingStart.Text);
            }
            foreach (var item in _listService)
            {
                service.FundingEnd = item.FundingEnd.Equals(DateTime.MinValue) ? (DateTime?)null :
                Convert.ToDateTime(txtFundingEnd.Text);
            }
            service.FundraisingForText = txtFundraisingForText.Text;
            service.FundraisingNeeds = txtFundraisingNeeds.Text;
            foreach (var item in _listService)
            {
                service.FundraisingRequiredBy = item.FundraisingRequiredBy.Equals(DateTime.MinValue) ?
                    (DateTime?)null : Convert.ToDateTime(txtFundraisingRequired.Text);
            }
            service.FundraisingWhy = txtFundraisingWhy.Text;
            foreach (var item in _listService)
            {
                service.FundraisingCompletedDate = item.FundraisingCompletedDate.Equals
                    (DateTime.MinValue) ? (DateTime?)null : Convert.ToDateTime
                    (txtFundraisingComplete.Text);
            }
            service.FundraisingDonorAmount = txtFDonorAmount.Text;
            foreach (var item in _listService)
            {
                service.FundraisingDonationDate = item.FundraisingDonationDate.Equals
                    (DateTime.MinValue) ? (DateTime?)null : Convert.ToDateTime(txtFDonationDate.Text);
            }

            service.FundraisingDonationIncremental = chkFDonationIncremental.Checked;
            service.IsActive = chkServiceActive.Checked;
            if (_serviceBiz.UpdateServices(service, _serviceId, serviceName))
            {
                if (Session.Contents["contact"] != null)
                {
                    Session["contact"] = null;
                }
                if (Session.Contents["contact1"] != null)
                {
                    Session["contact1"] = null;
                }
                Response.Redirect("/Pages/Views/Service.aspx");
            }
            else
            {
                lbMessage.Text = "Have problems when update or Service Name already exist ! " +
                                 "Please input service name another";
            }

        }

        /// <summary>
        /// Handles the SelectedIndexChanged event of the cboServiceType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void cboServiceType_SelectedIndexChanged(object sender, EventArgs e)
        {
            CheckTabs();

        }

        /// <summary>
        /// Handles the CheckedChanged event of the chkFContinuationNeeded control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void chkFContinuationNeeded_CheckedChanged(object sender, EventArgs e)
        {
            if (chkFContinuationNeeded.Checked)
            {
                txtFCAmount.Enabled = true;
                txtFCDetail.Enabled = true;
            }
            else
            {
                txtFCAmount.Enabled = false;
                txtFCDetail.Enabled = false;
            }
        }

        /// <summary>
        /// Handles the Click event of the btnFundingStart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnFundingStart_Click(object sender, EventArgs e)
        {
            if (calFundingStart.Visible == false)
            {
                calFundingStart.Visible = true;
                btnFundingStart.Text = "-";
            }
            else
            {
                calFundingStart.Visible = false;
                btnFundingStart.Text = "+";
            }
        }

        /// <summary>
        /// Handles the SelectionChanged event of the calFundingStart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void calFundingStart_SelectionChanged(object sender, EventArgs e)
        {
            txtFundingStart.Text = calFundingStart.SelectedDate.ToString("MM/dd/yyyy");
            calFundingStart.Visible = false;
            btnFundingStart.Text = "+";
        }

        /// <summary>
        /// BTNs the funding end click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void BtnFundingEndClick(object sender, EventArgs e)
        {
            if (calFundingEnd.Visible == false)
            {
                calFundingEnd.Visible = true;
                btnFundingEnd.Text = "-";
            }
            else
            {
                calFundingEnd.Visible = false;
                btnFundingEnd.Text = "+";
            }
        }

        /// <summary>
        /// Cals the funding end selection changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void CalFundingEndSelectionChanged(object sender, EventArgs e)
        {
            txtFundingEnd.Text = calFundingEnd.SelectedDate.ToString("MM/dd/yyyy");
            calFundingEnd.Visible = false;
            btnFundingEnd.Text = "+";
        }

        /// <summary>
        /// BTNs the fundraising required click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void BtnFundraisingRequiredClick(object sender, EventArgs e)
        {
            if (calFundraisingReqiured.Visible == false)
            {
                calFundraisingReqiured.Visible = true;
                btnFundraisingRequired.Text = "-";
            }
            else
            {
                calFundraisingReqiured.Visible = false;
                btnFundraisingRequired.Text = "+";
            }
        }

        /// <summary>
        /// Cals the fundraising reqiured selection changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void CalFundraisingReqiuredSelectionChanged(object sender, EventArgs e)
        {
            txtFundraisingRequired.Text = calFundraisingReqiured.SelectedDate.ToString("MM/dd/yyyy");
            calFundraisingReqiured.Visible = false;
            btnFundraisingRequired.Text = "+";
        }

        /// <summary>
        /// BTNs the fundraising complete click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void BtnFundraisingCompleteClick(object sender, EventArgs e)
        {
            if (calFundraisingComplete.Visible == false)
            {
                calFundraisingComplete.Visible = true;
                btnFundraisingComplete.Text = "-";
            }
            else
            {
                calFundraisingComplete.Visible = false;
                btnFundraisingComplete.Text = "+";
            }
        }

        /// <summary>
        /// Cals the fundraising complete selection changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void CalFundraisingCompleteSelectionChanged(object sender, EventArgs e)
        {
            txtFundraisingComplete.Text = calFundraisingComplete.SelectedDate.ToString("MM/dd/yyyy");
            calFundraisingComplete.Visible = false;
            btnFundraisingComplete.Text = "+";
        }

        /// <summary>
        /// BTNs the F donation date click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void BtnFDonationDateClick(object sender, EventArgs e)
        {
            if (calFDonationDate.Visible == false)
            {
                calFDonationDate.Visible = true;
                btnFDonationDate.Text = "-";
            }
            else
            {
                calFDonationDate.Visible = false;
                btnFDonationDate.Text = "+";
            }
        }

        /// <summary>
        /// Cals the F donation date selection changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void CalFDonationDateSelectionChanged(object sender, EventArgs e)
        {
            txtFDonationDate.Text = calFDonationDate.SelectedDate.ToString("MM/dd/yyyy");
            calFDonationDate.Visible = false;
            btnFDonationDate.Text = "+";
        }

        /// <summary>
        /// CHKs the fundraising donor checked changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void ChkFundraisingDonorCheckedChanged(object sender, EventArgs e)
        {
            txtFDonorAmount.Enabled = chkFundraisingDonor.Checked;
        }

        protected void chkFundraisingComplete_CheckedChanged(object sender, EventArgs e)
        {
            btnFundraisingComplete.Enabled = chkFundraisingComplete.Checked;
        }
    }
}